﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Adp.Core.Attribute;
using Adp;
using Adp.Common;
using Adp.Core.Services;
using System.Security.Cryptography;
using System.Net;
using Yqd.Enm;
using Yqd.Controllers;
using Yqd.Models;
using System.Threading.Tasks;
using System.Threading;
using Microsoft.Extensions.Hosting;

namespace Yqd.Core
{
    public class RankHostService : BackgroundService
    {
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                RankService.UpdateUnitRank();
                Thread.Sleep(3000);
                await Task.Delay((1000 * 60 * 60), stoppingToken);
            }
        }

    }

    public class UpDataToYiWuHostService : BackgroundService
    {
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                RankService.UpQMDataToYiWu();
                Thread.Sleep(3000);
                await Task.Delay((1000 * 60 * 60), stoppingToken);
            }
        }

    }

    public class workNotificationHostService : BackgroundService
    {
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                RankService.workNotification();
                Thread.Sleep(3000);
                await Task.Delay((1000 * 60 * 10), stoppingToken);
            }
        }

    }



    public class UpQuotaTableHostService : BackgroundService
    {
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                RankService.UpQuotaTable();
                Thread.Sleep(3000);
                await Task.Delay((1000 * 60 * 60), stoppingToken);
            }
        }

    }
}
